/*
 * 全局初始化
 *
 * @Author: 谢力 843926058@qq.com
 * @Date:   2018-06-06 14:08:51
 * @Last Modified by:   谢力
 * @Last Modified time: 2018-06-06 14:08:56
 */
// import Vue from 'vue';
import App from './App';
import store from './store';
import router from './router';
import './http';
import './filter';
import './directive';
import './utils/native';
import './utils/wx';
import axios from 'axios';
import Qs from 'qs';
import preventReClick from '@/utils/noDbClick'
Vue.use(preventReClick)
// import Vconsole from 'vconsole'
// const vConsole = new Vconsole()
// Vue.use(vConsole)

// 引入axios进行数据请求
Vue.prototype.$axios = axios
Vue.prototype.Qs = Qs


// 给axios对象设置一个全局的默认baseURL,后续接口可以不用写baseURL了
let protocol = window.location.protocol //协议
let host = window.location.host //主机
let pathname = window.location.pathname.split('/')
let reg = /^localhost+/
if (pathname.length >= 5) {
    host = window.location.host + '/' + pathname[1] + '/'
} else {
    host = window.location.host + '/'
}
console.log(host.split(':'))
if (reg.test(host)) {
    //若本地项目调试使用
    // axios.defaults.baseURL = 'https://app10.downline.cn/wholefarm_demo_project_001/'
    // axios.defaults.baseURL = 'http://shupai.downline.cn/';
    // axios.defaults.baseURL = 'http://app004.downline.cn/';
    axios.defaults.baseURL = protocol + "//" + host + 'api';
    // axios.defaults.baseURL = protocol + "//" + host;
    // axios.defaults.baseURL = protocol + "//" + host.split(':')[0] + ":8989/api/";
    // axios.defaults.baseURL = 'https://www.jinglintu.cn/';
    // axios.defaults.baseURL = 'http://www.gtiis.com/';
} else {
    //动态请求地址             协议               主机
    axios.defaults.baseURL = protocol + "//" + host
}
Vue.prototype.baseUrl = axios.defaults.baseURL
axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
// 给axios配置请求拦截器
axios.interceptors.request.use(
    function (config) {
        // 每次请求的时候，都会自动给config.headers增加一个Authorization
        // config.headers.Authorization = localStorage.getItem('token')
        return config
    },
    function (error) {
        console.log(error)
        // 对请求错误做些什么
        return Promise.reject(error)
    }
)
// 给axios配置响应拦截器
axios.interceptors.response.use(
    function (response) {
        // 通过响应拦截器，直接返回 res.data
        return response.data
    },
    function (error) {
        console.log(error)
        // 对响应错误做点什么
        return Promise.reject(error)
    }
)

Vue.config.productionTip = false

/* 引入MintUI组件库 */
import {
    Swipe,
    SwipeItem,
    Lazyload,
    DatetimePicker
} from 'mint-ui';
import 'mint-ui/lib/style.css'
Vue.component(Swipe.name,Swipe);
Vue.component(SwipeItem.name,SwipeItem);
Vue.component(DatetimePicker.name, DatetimePicker);
Vue.use(Lazyload,{
    loading:require('@/assets/images/base/load.png'),
    error:require('@/assets/images/logo.png'),
    attempt:1
});

/* 引入自定义样式 */
import './assets/iconfont/iconfont.css';
import './assets/css/common.less';
import './assets/css/main.less';

/* 引入复制功能 */
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard);

/* 引入echarts图表 */
import echarts from 'echarts';
Vue.prototype.$echarts=echarts;

/* 引入公共基础混入 */
import mixinCommon from './utils/mixins/common';
Vue.mixin(mixinCommon);

/* 引入自定义组件 */
import './components/theme/index.less';
import bsxUI from './components';
Vue.use(bsxUI);

/* 引入FastClick插件 */
// import FastClick from 'fastclick';
// FastClick.attach(document.body);

/* 引入日历插件 */
import Calendar from 'vue-mobile-calendar';
Vue.use(Calendar)

Vue.config.productionTip=false;

/* eslint-disable no-new */
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
import Vue from 'vue';
import Vant from 'vant';
import 'vant/lib/index.css';

Vue.use(Vant);
/** 文件上传 */
import { upload } from '@/utils/upload';
Vue.prototype.$upload = upload;
//引入v-viewer插件，实现点击全局放大、可以进行手势缩放功能
// import Vue from 'vue';
import Viewer from 'v-viewer';
import 'viewerjs/dist/viewer.css';
Vue.use(Viewer, {
    defaultOptions: {

        zIndex:1,

        inline:false,

        button:true,

        navbar:false,

        title:false,

        toolbar:false,

        tooltip:true,

        movable:true,

        zoomable:true,

        rotatable:false,

        scalable:false,

        transition:true,

        fullscreen:true,

        keyboard:false,

        loop:false,

    }
})